/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package javamail.web.util;

/**
 *
 * @author sriram
 */
public enum eGenOption {
    NIL(0, "NIL"), HOST(1, "Host:"), SERVER(2,"Server:"), 
    LMODIFIED(3, "Last-Modified:"), ACCEPT_RANGE(4, "Accept-Ranges:"), 
    EXPIRES(5, "Expires:"), CONTENT_TYPE(6, "Content-Type:"), 
    KEEP_ALIVE(7, "Keep-Alive:"), CONN(8, "Connection:"), 
    CACHE(9, "Cache-Control"), EOL(10, "\r\n"), MAXOPT(11, "NIL");

    private final int index;
    private final String str;
    
    eGenOption(int id, String string) {
        this.index = id;
        this.str = string;
    }
    
    public int toInt() {
        return index;
    }
 
    public String toString() {
        return str;
    }
 
    public static eGenOption fromString(final String str) {
        for (eGenOption opt : eGenOption.values()) {
            if (opt.toString().equalsIgnoreCase(str)) {
                return opt;
            }
        }
        return NIL;
    }
 
    public static eGenOption fromInt(final int index) {
        for (eGenOption opt : eGenOption.values()) {
            if (opt.index == index) {
                return opt;
            }
        }
        return NIL;
    }
}
